package fantasyfootball.data.entities;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * Class: 605.441 
 * Group: Richard Koretke, Kay Jantharasorn, Israel Rivera.
 * 
 * @author Israel Rivera
 * 
 */
@Entity(name="FantasySchedule")
public class FantasySchedule implements Serializable{

	private static final long serialVersionUID = -4162771470034409532L;
	
	private Integer scheduleID;
	private FantasyTeam homeTeam;
	private Integer week;
	private FantasyTeam awayTeam;
	private boolean isCompleted;
	private BigDecimal homePoints;
	private BigDecimal awayPoints;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ScheduleID", nullable=false)
	public Integer getScheduleID() {
		return scheduleID;
	}

	public void setScheduleID(Integer scheduleID) {
		this.scheduleID = scheduleID;
	}
	
	@JoinColumn(name="HomeTeam", nullable=false)
	@ManyToOne(fetch=FetchType.LAZY, optional=false)
	public FantasyTeam getHomeTeam() {
		return homeTeam;
	}

	public void setHomeTeam(FantasyTeam homeTeam) {
		this.homeTeam = homeTeam;
	}
	
	@Column(name="Week", nullable=true)
	public Integer getWeek() {
		return week;
	}

	public void setWeek(Integer week) {
		this.week = week;
	}
	
	@JoinColumn(name="AwayTeam", nullable=false)
	@ManyToOne(fetch=FetchType.LAZY, optional=false)
	public FantasyTeam getAwayTeam() {
		return awayTeam;
	}

	public void setAwayTeam(FantasyTeam awayTeam) {
		this.awayTeam = awayTeam;
	}
	
	@Column(name="IsCompleted", nullable=false)
	public boolean isCompleted() {
		return isCompleted;
	}

	public void setCompleted(boolean isCompleted) {
		this.isCompleted = isCompleted;
	}
	
	@Column(name="HomePoints", nullable=false)
	public BigDecimal getHomePoints() {
		return homePoints;
	}

	public void setHomePoints(BigDecimal homePoints) {
		this.homePoints = homePoints;
	}
	
	@Column(name="AwayPoints", nullable=false)
	public BigDecimal getAwayPoints() {
		return awayPoints;
	}

	public void setAwayPoints(BigDecimal awayPoints) {
		this.awayPoints = awayPoints;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((scheduleID == null) ? 0 : scheduleID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FantasySchedule other = (FantasySchedule) obj;
		if (scheduleID == null) {
			if (other.scheduleID != null)
				return false;
		} else if (!scheduleID.equals(other.scheduleID))
			return false;
		return true;
	}
}